home *** CD-ROM | disk | FTP | other *** search
INI File | 2001-09-10 | 2.9 KB | 85 lines |
- [Name]
- MouseTurnOver - From Matthew's Motion Suite.
- By Matthew Peterson, matthew@pinoko.berkeley.edu
-
- [Description]
- 2-19-2000
- Drop this on a sprite to make it a two-sided Button.
- When the mouse moves over, it turn around to let you
- see the other side. Can be usefull in making card games.
-
- [Parameters]
-
- Side 1 Image Index, MP_SpinSideOneImage,1
- Side 2 Image Index, MP_SpinSideTwoImage,2
-
-
- [Mouse Enter]
- spritevars turningover
- turningover = 1
-
-
- [Mouse Exit]
- SpriteVars turningover turnback
- if(not turningover)
- turnback = true
- endif
-
- [Frame loaded]
- spritevars turningover turnfirstimage turnsecondimage originalspincenterx originalspincentery spincenterx spincentery spinanglestep originalheight
-
- turningover = 0
- spriteofid($thisspriteid).executeevent(200082)
- originalheight = spriteofid($thisspriteid).boundsbottom - spriteofid($thisspriteid).boundstop
- originalspincenterx = spincenterx
- originalspincentery = spincentery
- spinanglestep = 180/9
- turnfirstimage = $MP_SpinSideOneImage//This can be change on the fly if you want to have multiple images on the front
- turnsecondimage = $MP_SpinSideTwoImage//You can change on the fly to have multiple images on the reverse side
-
- [Idle]
- SpriteVars turningover turnback turnfirstimage turnsecondimage spinangle spinanglestep originalheight originalspincenterx originalspincentery spincenterx spincentery spinanglestep
- localvars temporaryx temporaryy spinheight
- //Figure out when to stop, and which direction to turn
- if(turningover)
- spinangle = (spinangle + spinanglestep*turningover + 720 ) rem 360
- if(turningover = 1 and spinangle > 179)
- spinangle = 180
- if(mousehorizontal > boundsleft and mousehorizontal < boundsright and mousevertical > boundstop and mousevertical < boundsbottom)
- turningover = 0
- else
- turningover = -1
- endif
- elseif(turningover = -1 and spinangle < 2)
- spinangle = 0
- if(mousehorizontal > boundsleft and mousehorizontal < boundsright and mousevertical > boundstop and mousevertical < boundsbottom)
- turningover = 1
- else
- turningover = 0
- endif
- endif
- setimageindexto(turnfirstimage)
- resetmatrix
- rotate(spinangle)
- spinheight = (SecondCornerY - FirstCornerY) * 0.1
- if(spinangle <= 90 or spinangle >= 270)
- Stretch(FirstCornerX,SecondCornerY - spinheight,SecondCornerX, SecondCornerY + spinheight, SecondCornerX,SecondCornerY + originalheight - spinheight,FirstCornerX,SecondCornerY + originalheight + spinheight)
- else
- setimageindexto(turnsecondimage)
- Stretch(SecondCornerX, SecondCornerY + spinheight,FirstCornerX,SecondCornerY - spinheight,FirstCornerX,SecondCornerY + originalheight + spinheight, SecondCornerX,SecondCornerY + originalheight - spinheight)
- endif
- executeevent(200082)
- MoveBy(originalspincenterx- spincenterx,originalspincentery - spincentery)
- else
- if(turnback)
- turningover = -1
- turnback = false
- endif
- endif
-
- [200082 MP_CalculateSpinCenter]
- spritevars spincenterx spincentery
- //get the center of the sprite
- spincenterx = (boundsleft + boundsright)/2
- spincentery = (boundstop + boundsbottom)/2
-